package com.fit.pages;

import java.util.LinkedList;

import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.beans.CarBean;
import com.fit.interfaces.Borrow;
import com.fit.interfaces.Car;
import com.fit.interfaces.Reservation;
import com.fit.interfaces.User;
import com.fit.service.Cars;

public class EntryCar {

	@Property
	@Persist
	private Car car;
	
	@Inject
	private Cars cars;
	@SetupRender
	public void createObject(){
		car = new CarBean();
		car.setBorrow(new LinkedList<Borrow>());
		car.setReservation(new LinkedList<Reservation>());
	}
	void onSuccess(){
		cars.save(car);
	}
	
	@SessionState
	private User user;
	
	private boolean userExists;
	
	Object onActivate(){
		if (!userExists) return Login.class;
		return null;
	}
}
